home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / inet / ien / ien-198 < prev    next >
Text File  |  1988-12-01  |  34KB  |  1,058 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.                                                              INDRA
  7.                                                             Working
  8.                                                              Paper
  9.      IEN 198
  10.      INDRA Note 1041
  11.      15th. September 1981
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.             Extended Memory MOS for a UNIX Development Host
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.                               Robert Cole
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.           ABSTRACT: This note describes a version of  the
  42.                RSRE  Extended Memory MOS that can be used
  43.                with a UNIX development  host.   The  run-
  44.                time  MOS system design is explained.  The
  45.                linking and loading phases are  described.
  46.                Documentation is included in an appendix.
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.                      Department of Computer Science
  54.                        University College, London
  55.  
  56.  
  57.      Extended Memory MOS for                                IEN 198
  58.      a UNIX Development Host                        INDRA Note 1152
  59.  
  60.  
  61.  
  62.  
  63.                               C O N T E N T S
  64.  
  65.  
  66.        1.  Introduction..............................................2
  67.  
  68.        2.  Linking on UNIX...........................................3
  69.  
  70.        3.  Loading...................................................5
  71.  
  72.        4.  MOS Initialisation........................................7
  73.  
  74.        5.  MOS Runtime...............................................7
  75.  
  76.        6.  DDT.......................................................7
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.                                  - 1 -               [Robert Cole]
  114.  
  115.  
  116.      1. Introduction
  117.  
  118.         Recently a version of  MOS  (Micro  Operating  System)  was
  119.      developed  at RSRE [1] which enabled the extra memory capacity
  120.      of 11/23 and 11/34 computers to be used.  The development  was
  121.      carefully  designed  to increase the buffer space available to
  122.      all processes without adding significant  'context  switching'
  123.      overheads.  A  further  development  at  UCL has used the same
  124.      design, but for use on a UNIX development host.  Standard UNIX
  125.      software  does  not  cater  for  extended memory systems to be
  126.      built by users.  As a result a new linker was produced, giving
  127.      some  flexibility to the resulting MOS system.  It was decided
  128.      to extend the EMMOS system of RSRE  by  using  both  USER  and
  129.      KERNEL  addressing  modes  to  provide  extra  protection  and
  130.      addressing space.
  131.  
  132.         Figure 1 shows the two address mode maps that are  used  at
  133.      runtime.
  134.  
  135.                             page
  136.              ___________             ___________
  137.              |         |             |  stack  |
  138.              |         |             |---------|
  139.              |  I/O    |             | process |
  140.              |  page   |      7      | buffers |
  141.              |         |             |---------|
  142.              |         |             |  data   |
  143.              |_________|             |_________|
  144.              |         |             | process || write
  145.              |   DDT   |      6      |  text   || protected
  146.              |_________|             |_________||
  147.              |         |             |         |
  148.              :         :      5      :         :
  149.              : shared  :      :      : shared  :
  150.              : buffers :      :      : buffers :
  151.              :         :      2      :         :
  152.              |_________|             |_________|
  153.              |PCTs+DCTs|      1      |PCTs+DCTs||
  154.              | drivers |             | drivers || write
  155.              |   MOS   |      0      |   MOS   || protected
  156.              |_________|             |_________||
  157.                kernel                   user
  158.                       Figure 1. Runtime Memory Map
  159.  
  160.      Here the I/O page is only available to  the  Kernel  mode  and
  161.      both  MOS  and  the  process instructions are protected during
  162.      process execution.  The UNIX object format naturally separates
  163.      text  (instructions)  from  data  (program variables) so it is
  164.      possible to use this in our design.  The last page of the user
  165.      address  space  is  loaded with the process data at the bottom
  166.      and the process stack is created at  the  top.   The  full  8K
  167.      bytes  is  allocated  so any space left between can be used as
  168.  
  169.  
  170.                                  - 2 -               [Robert Cole]
  171.  
  172.  
  173.  
  174.      Extended Memory MOS for                                IEN 198
  175.      a UNIX Development Host                        INDRA Note 1152
  176.  
  177.      process private buffer space and managed by the system  buffer
  178.      management code.
  179.  
  180.         Buffers, which are common to  all  processes,  are  set  up
  181.      above  the  MOS  Kernel and below the processes.  Normally the
  182.      processes are all loaded in pages 6  and  7,  however  a  very
  183.      large  process  may  force  this boundary down to page 5.  The
  184.      size of the  MOS  Kernel  will  vary  from  system  to  system
  185.      depending on the number of processes, the number and nature of
  186.      devices, and any other code that is shared between  processes.
  187.      The  MOS  Kernel size is rounded up to the next page boundary.
  188.      Figure 1 shows 2 pages being used for MOS.   The  Kernel  mode
  189.      (and MOS initialisation) stack is placed at the top of the MOS
  190.      Kernel space.  Thus the shared buffer area is squeezed by code
  191.      requirements,  however  figure  1 shows 4 x 8K of buffer space
  192.      (half the virtual address space) and  is  probably  the  worst
  193.      case.   In  addition  most  processes  will  have some private
  194.      buffer space.
  195.  
  196.         During MOS execution the  processes  are  'swapped  in'  by
  197.      manipulating  the  Memory  Management  Unit  (MMU)  registers.
  198.      Apart from loading these registers to swap in  a  new  process
  199.      the  only  other overhead of the extended memory system is the
  200.      need to disable the write protection on the MOS Kernel when an
  201.      EMT  from a process occurs.  The protection is re-enabled when
  202.      control is returned to the process text.
  203.  
  204.         The remainder of this note describes in detail the linking,
  205.      loading,   and   runtime   phases.    The  appendices  contain
  206.      documentation on building the extended memory MOS.
  207.  
  208.  
  209.      2. Linking on UNIX
  210.  
  211.         The standard UNIX linker (ld) is only capable of building a
  212.      single  64K  byte  module.   Using a version of ld from MITRE,
  213.      which had some modifications for building an overlay,  ld  was
  214.      extended.   From the description above it can be seen that the
  215.      MOS Kernel is in the address space of each process,  but  that
  216.      the  process  (text  and  data)  address  spaces  are mutually
  217.      exclusive.  This arrangement is most like an  overlay  system,
  218.      with  the  MOS  Kernel  as  the root.  The program, lk (lk for
  219.      link), was used to build the root and  link  in  each  overlay
  220.      separately.   Obviously  each overlay should be able to access
  221.      the root, but not vice versa.
  222.  
  223.         The lk program uses two symbol tables, one  for  the  root,
  224.      and  one  for  the  current  overlay.  The overlay symbols are
  225.      purged when the overlay definition is complete and the overlay
  226.      has been linked.  A mechanism was required for MOS to identify
  227.      overlay code at runtime for swapping, as well as for  them  to
  228.  
  229.  
  230.                                  - 3 -               [Robert Cole]
  231.  
  232.  
  233.      Extended Memory MOS for                                IEN 198
  234.      a UNIX Development Host                        INDRA Note 1152
  235.  
  236.      be  easily  indicated  from  the  C  configuration  file.  The
  237.      mechanism chosen is to label each overlay by a tag  symbol  at
  238.      link  time.  The symbol is given a unique value by the linker.
  239.      The symbol itself can be used in C programs, and later in DDT,
  240.      to identify a particular overlay (process).
  241.  
  242.      An example command sequence to lk could be:
  243.           lk mos.o config.o \
  244.           { _tag1 -n -b 0140000 -e _ent1 proc1.o lib.a }
  245.  
  246.        where
  247.           { ... } defines an overlay
  248.           _tag1 is the tag symbol, the leading underscore is
  249.            required where the symbol is referenced in C code
  250.           -b 0140000 gives the base address at which the overlay
  251.            code is to linked (page 6)
  252.           -e _ent1 defines the entry address for this overlay
  253.  
  254.         The -b  flag is used to relocate the overlay  code  to  the
  255.      top  end of the address space.  The -n flag causes the data to
  256.      be relocated to the next page boundary (if possible).  At  UCL
  257.      we  use a modified version of cc, called mcc, to build the MOS
  258.      load file.  Mcc will expand the "{ tagn" to become  "{ tagn" -
  259.      n -b 014000"   and  the  "}"  become  "-l }",  thus  providing
  260.      defaults.
  261.  
  262.         The  object  code  output  is  organised  as  a  number  of
  263.      subfiles,  one  for the root, and one for each overlay.  These
  264.      subfiles are packed into a single output file using the ar (V)
  265.      format.   Size (I)  and  nm (I)  have  been modified to accept
  266.      files in ar format and operate on the subfiles.
  267.  
  268.         From the runtime map, fig. 1, it can be seen that DDT is in
  269.      the  Kernel  address space, but at the opposite end to that of
  270.      MOS.  To achieve this lk recognises the tag "ddt" and marks it
  271.      as being in the root (by the magic word) but treats the module
  272.      as an overlay for linking purposes.
  273.  
  274.         The normal a.out (V) header has been modified by using  the
  275.      unused  word to include the tag symbol value and the base page
  276.      into which the overlay should be swapped.  The format is now:
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.                                  - 4 -               [Robert Cole]
  289.  
  290.  
  291.  
  292.      Extended Memory MOS for                                IEN 198
  293.      a UNIX Development Host                        INDRA Note 1152
  294.  
  295.      typedef struct filhdr { /* a.out format header */
  296.              int     magicw;
  297.      #define VMAGIC  0405
  298.      #define FMAGIC  0407
  299.      #define NMAGIC  0410
  300.      #define IMAGIC  0411
  301.      #define ROOTMAGIC 0515 /* root file in overlay system */
  302.      #define OVNMAGIC  0525 /* overlay with separate I and D */
  303.      #define OVFMAGIC  0535 /* overlay with contiguous I and D */
  304.              int     tsize;
  305.              int     dsize;
  306.              int     bsize;
  307.              int     ssize;
  308.              int     entrypt;
  309.              char    tag, page;      /* for MOS overlays */
  310.              int     relflg;
  311.      } FILHDR;
  312.  
  313.  
  314.      3. Loading
  315.  
  316.         Once the complete MOS system has been linked and  is  ready
  317.      in  the  ar  format  file; it has to be loaded into the LSI or
  318.      PDP-11.  To manage the MMU and set up the overlays  ready  for
  319.      swapping  a special loader is used in the target computer.  At
  320.      UCL we load this as an  ordinary  program  using  a  down-line
  321.      loader.   The  program  is  then  automatically started by the
  322.      primary bootstrap and continues as the (secondary) bootstrap.
  323.  
  324.         Each subfile is passed to the secondary  bootstrap  in  two
  325.      parts,  first  the  16 byte a.out header, followed by the text
  326.      and data.  The a.out header enables the bootstrap  to  see  if
  327.      the file contains root code or is an overlay.
  328.  
  329.         If the subfile is a root file (magic word  =  0515)  it  is
  330.      loaded  into the 1st 6 physical pages and the MMU is not used.
  331.      Any symbols associated with the root are placed at the end  of
  332.      the last physical page (page 30), the amount of space left for
  333.      the root symbols is an assembly constant  shared  between  the
  334.      virtual  bootstrap, virtual MOS and DDT.  The page byte in the
  335.      a.out header allows loading to begin  on  any  page  boundary.
  336.      Note that DDT is loaded into page 6 using this mechanism.  The
  337.      secondary boot operates from the very top of physical  page  6
  338.      so that DDT should not overwrite this.
  339.  
  340.         If the subfile is an overlay it is  loaded  above  physical
  341.      location  0160000.   The text and data are loaded contiguously
  342.      in 1K byte blocks from UNIX.  When the text and data have been
  343.      loaded  (the a.out header contains the size, this is used as a
  344.      check against the amount received) the physical address of the
  345.  
  346.  
  347.                                  - 5 -               [Robert Cole]
  348.  
  349.  
  350.  
  351.      Extended Memory MOS for                                IEN 198
  352.      a UNIX Development Host                        INDRA Note 1152
  353.  
  354.      top of the 8K process page boundary is calculated.  The layout
  355.      of a process is shown in Fig. 2.
  356.  
  357.         <--64---><------text-----><------8K------><--symbols-->
  358.           bytes                         bytes
  359.         _________________________________._____________________
  360.         !   H    !                !      .        !            |
  361.         !   E    !                !   D  .        !            |
  362.         !   A    !      TEXT      !   A  .        !            |
  363.         !   D    !                !   T  .        !            |
  364.         !   E    !                !   A  .        !            |
  365.         !   R    !                !      .        !            |
  366.         !________!________________!______.________!____________|
  367.              ! denotes a 64 byte block boundary
  368.  
  369.                       Figure 2. Overlay load map.
  370.  
  371.         The a.out header is copied into the first  64  byte  block,
  372.      this  block  is  used as a control block for the overlay.  The
  373.      format of this control block is:
  374.  
  375.      typedef struct { /* overlay header block structure */
  376.        int magic;      /* magic word */
  377.        int tsize;
  378.        int dsize;
  379.        int bsize;
  380.        int ssize;
  381.        int entry; /* entry address for process */
  382.        char tag;
  383.        char page; /* same as a.out header up to here */
  384.        int used;  /* indicates overlay already used */
  385.        int memlo; /* address of first free loc in o/v */
  386.        int next;  /* points to next overlay header */
  387.        int par[16]; /* MMU register contents to */
  388.        int pdr[16]; /* 'swap' this process in */
  389.      } OVERLAY_HEADER;
  390.  
  391.         The base of the 8K page is, of course, the first data byte.
  392.      This  means  there  is  a  hole  in  the process address space
  393.      between the end of the text and the first word  of  the  data.
  394.      There  is  no  physical  memory assigned to this area.  If the
  395.      subfile has any symbols these are loaded  above  the  extended
  396.      data  page.   When  the data and text have been loaded the bss
  397.      area is set to zero, this only occurs at load time.  When  the
  398.      symbols have been loaded the virtual loader calculates the PAR
  399.      and PDR register contents for  the  process  by  assuming  all
  400.      unloaded  pages  are  allocated to the low physical memory and
  401.      are full (all 8K in use).  The loaded pages are given the  PAR
  402.      and  PDR  values  needed to 'swap' in this process.  The first
  403.      location in the process  private  buffer  pool  is  calculated
  404.      (size  of  data  +  bss  +  2 + 0160000)  and the PAR contents
  405.  
  406.  
  407.                                  - 6 -               [Robert Cole]
  408.  
  409.  
  410.      Extended Memory MOS for                                IEN 198
  411.      a UNIX Development Host                        INDRA Note 1152
  412.  
  413.      needed to access the next process control block.  In this  way
  414.      the  first  overlay  control  block  is  always at 0160000 and
  415.      subsequent overlays can be found  by  using  the  chain.   The
  416.      virtual  loader  (and  MOS)  do all address calculation in PAR
  417.      content values.
  418.  
  419.         Thus the loader sets up the process, and the necessary  MMU
  420.      register values, to enable MOS to use the overlay easily.
  421.  
  422.  
  423.      4. MOS Initialisation
  424.  
  425.         Apart from some modification to the  synchronous  I/O  code
  426.      the changes to MOS were in the once only system initialisation
  427.      code.
  428.  
  429.         The MMU is enabled as soon as MOS  loads  the  kernel  mode
  430.      registers  to  provide  the same mapping as though the MMU was
  431.      disabled. A window page is used to map into  the  overlays  by
  432.      loading  a single PAR register with the values provided by the
  433.      loader.  Any spare physical memory between  the  last  overlay
  434.      and  the  MOS  Kernel  symbols  is  divided into 8K pieces and
  435.      initialised with a control block.  These may be used when  two
  436.      or more processes share the same text.
  437.  
  438.         The control block used for each overlay means there was  no
  439.      need  to increase the size of the Process Control Table (PCT),
  440.      this was convenient as the size is currently 32 bytes.
  441.  
  442.  
  443.      5. MOS Runtime
  444.  
  445.         As pointed out in [1] it is necessary  to  use  the  shared
  446.      buffer  area  for  all I/O and especially IORBs.  This was the
  447.      only change that needs to be made to MOS processes.   However,
  448.      some processes share routines and data space, these have to be
  449.      loaded in the Kernel.  All the facilities described in [2] are
  450.      available.
  451.  
  452.         The synchronous I/O routines (sin, sout,  bin,  bout)  will
  453.      copy  data  between  the  process  data  page  and  the shared
  454.      buffers, if necessary.
  455.  
  456.  
  457.      6. DDT
  458.  
  459.         The debugging program DDT is always loaded in the  extended
  460.      MOS.   This has the same commands and features as the ordinary
  461.      DDT.  In addition the  following  command  will  'swap  in'  a
  462.      process, and its symbol table.
  463.  
  464.  
  465.                                  - 7 -               [Robert Cole]
  466.  
  467.  
  468.  
  469.      Extended Memory MOS for                                IEN 198
  470.      a UNIX Development Host                        INDRA Note 1152
  471.  
  472.           <tag>$l - load an overlay
  473.           $l      - load the 'normal' address space
  474.  
  475.         The <tag> should be a tag symbol used in  linking.   If  no
  476.      tag  is  given;  DDT  itself,  and the I/O page are mapped in.
  477.      Processes can be swapped randomly in DDT, this does not affect
  478.      the running of the system.
  479.  
  480.         The only (apparent) facility not readily converted  is  the
  481.      use  of  single  step  over RTT and RTI instructions where the
  482.      address mode is changed by that instruction.
  483.  
  484.         Note, that when DDT is entered via a break  (breakpoint  or
  485.      single  step)  PS and SP contain the values in use at the time
  486.      of the break, thus are not necessarily the SP of the  mode  in
  487.      which  DDT  is  running.   Also when the break occured in user
  488.      mode the address space contains the user process, not the  I/O
  489.      page.
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.                                  - 8 -               [Robert Cole]
  525.  
  526.  
  527.  
  528.      Extended Memory MOS for                                IEN 198
  529.      a UNIX Development Host                        INDRA Note 1152
  530.  
  531.  
  532.  
  533.  
  534.      References
  535.  
  536.  
  537.       1. Wiseman, S.R., Davies, B.H., Memory Management Extensions
  538.          to the SRI Micro Operating System for PDP- 11/23/34/40,
  539.          IEN 136, May 1980
  540.  
  541.       2. Cole & Treadwell, MOS User Guide, 2nd Ed.,
  542.          Indra Note 1042
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.                                  - 9 -               [Robert Cole]
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.                                 APPENDIX
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.         This appendix contains an example of building a virtual MOS
  605.      system   using   the   normal   mechanisms,  plus  the  system
  606.      documentation for mcc and lk,
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.  
  616.  
  617.  
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.                              - Appendix 2 -           [Robert Cole]
  641.  
  642.  
  643.  
  644.      Extended Memory MOS for                                IEN 198
  645.      a UNIX Development Host                        INDRA Note 1152
  646.  
  647.                    Example of Building a vMOS System
  648.  
  649.         The vMOS system is defined in a cnf file in the same way as
  650.      an  ordinary  system.   The difference is that the lk 'tag' is
  651.      used instead of the entry address.  In our example a TCP  test
  652.      system is built:
  653.  
  654.      extern   monitor, control, vcs, tcp, inet, monsl;
  655.  
  656.      PCTE pcts[]     {
  657.        setpcte("opcon", &control, &dt1i, &dt1o, 300, 0, 0),
  658.        setpcte("tcp", &tcp, &cty1, 0, 200, 0, 0),
  659.        setpcte("internet", &inet, 0, 0, 300, 0, 0),
  660.        setpcte("cstest", &vcs, &cty2, 0, 200, 0, 0),
  661.        setpcte("monitor",&monitor, 0, 0, 200, 0, 0),
  662.        setpcte("monslave", &monsl, 0, 0, 200, 0, 0),
  663.              };
  664.  
  665.      Note that there is  no  mechanism  for  automatically  loading
  666.      complete  processes  so  the Internet and monitoring processes
  667.      are explicitly named.  For this  reason  there  is  a  special
  668.      version  of  the  TCP  process  that does not attempt to spawn
  669.      those processes.
  670.  
  671.         The commands to mcc must indicate all of the procceses.  In
  672.      this  example  a  large  number  of routines are loaded in the
  673.      kernel to enable them to be shared amongst processes.  In fact
  674.      this  is  to  do  with  the  monitoring and all that should be
  675.      shared is the name of the routine.
  676.  
  677.      mcc -o vtcptst tcpcnf.c vtcppnt.c monpid.c \
  678.      inprnt.c inaddr.c vprintf.o -l1 \
  679.      { control -e opcon opcmds.c -l1 } \
  680.      { vcs -e cstest cstest.o } \
  681.      { monitor -e vmontr -lv } \
  682.      { monsl -e monslave -lv } \
  683.      { tcp -e vtcpm -lv } \
  684.      { inet -e inetm -lv -l1 }
  685.  
  686.  
  687.         To show how mcc expands this  command  the  actual  command
  688.      line  to  lk  is  shown  below.  Note that new-lines have been
  689.      inserted to improve the clarity of the example.
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.                              - Appendix 3 -           [Robert Cole]
  700.  
  701.  
  702.  
  703.      Extended Memory MOS for                                IEN 198
  704.      a UNIX Development Host                        INDRA Note 1152
  705.  
  706.      lk -X /ucl/mos/lib/vmos.o -o vtcptst tcpcnf.o vtcppnt.o
  707.      monpid.o inprnt.o inaddr.o vprintf.o -l1
  708.      { _control -b 0140000 -n -e _opcon opcmds.o -l1 -l }
  709.      { _vcs -b 0140000 -n -e _cstest cstest.o -l }
  710.      { _monitor -b 0140000 -n -e _vmontr -lv -l }
  711.      { _monsl -b 0140000 -n -e _monslave -lv -l }
  712.      { _tcp -b 0140000 -n -e _vtcpm -lv -l }
  713.      { _inet -b 0140000 -n -e _inetm -lv -l1 -l }
  714.      ddtstk.o
  715.      { ddt -b 0140000 -s /ucl/mos/lib/vddt.o }
  716.      -l
  717.  
  718.  
  719.         When converting from an  ordinary  MOS  system  to  a  vMOS
  720.      system the 2 major problems are:
  721.  
  722.        1. Different processes that share  memory  or  routines,  or
  723.           even addresses.
  724.  
  725.        2. Searching libraries so that only  the  required  routines
  726.           are  built  into  an  overlay,  and  not  included in the
  727.           kernel.
  728.  
  729.  
  730.  
  731.  
  732.  
  733.  
  734.  
  735.  
  736.  
  737.  
  738.  
  739.  
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758.                              - Appendix 4 -           [Robert Cole]
  759.  
  760.  
  761.  
  762.  
  763.           LK(I)                 15th. September 1981                 LK(I)
  764.  
  765.  
  766.  
  767.           NAME
  768.                lk  -  link editor for Extended Memory MOS
  769.  
  770.           SYNOPSIS
  771.                lk [ { tag ] -sulxnebo name ...  [ } ]
  772.  
  773.           DESCRIPTION
  774.                Lk is a modification of ld(I)  that  can  build  an  overlay
  775.                system  of  the type used in the Extended Memory MOS system.
  776.                All the features of ld are supported.  If  no  overlays  are
  777.                defined  lk  behaves  exactly  the  same  as  ld,  only less
  778.                efficiently.
  779.  
  780.                Overlays are defined  by  enclosing  switches  and  filename
  781.                arguments  between curly brackets "{}".  Each overlay has to
  782.                have a name, thus the first argument after every open  curly
  783.                bracket  is  taken  as  the symbol naming that overlay.  The
  784.                symbol is known as the overlay tag.  Each  tag  is  given  a
  785.                unique value by lk.  The overlay definition syntax is:
  786.                                  { tag -sulxneb name... }
  787.  
  788.                Any arguments not bracketed are used  to  define  the  root.
  789.                Root  arguments  may  appear in any position between overlay
  790.                definitions.  All symbols defined in the root arguments  are
  791.                available  to  all  overlays.  Symbols defined in an overlay
  792.                are purged when processing of the overlay is complete.  Thus
  793.                it is not possible to have references between overlays.
  794.  
  795.                Lk produces output in  ar(V)  format.   The  root  and  each
  796.                overlay  are  separate subfiles in the output.  Each subfile
  797.                is a complete a.out(V) format file with symbols if required.
  798.                The default output name is "a.out".
  799.  
  800.                Where symbols are used in the argument list (in -e, -u,  and
  801.                as  the  overlay tag) they must be preceded by an underscore
  802.                if they are also defined in C programs.
  803.  
  804.                If any argument is a library, it is searched exactly once at
  805.                the  point  it  is  encountered  in the argument list.  Only
  806.                those routines defining an unresolved external reference are
  807.                loaded.   If  a  routine  from  a library references another
  808.                routine in the library, the referenced routine  must  appear
  809.                after  the  referencing  routine  in  the library.  Thus the
  810.                order of programs within libraries is important.
  811.  
  812.                Lk understands several  flag  arguments  which  are  written
  813.                preceded by a '-'.  Except for -l, they should appear before
  814.                the file names.
  815.  
  816.  
  817.  
  818.                                         - 1 -
  819.  
  820.  
  821.  
  822.  
  823.           LK(I)                 15th. September 1981                 LK(I)
  824.  
  825.  
  826.                The options suxXneb have a local effect when used within  an
  827.                overlay definition.  If used outside an overlay their effect
  828.                is global, but can be overridden by other flags or values.
  829.  
  830.                -s      'squash' the output,  that  is,  remove  the  symbol
  831.                    table  and relocation bits to save space (but impair the
  832.                    usefulness of the debugger).  This information can  also
  833.                    be removed by strip.
  834.  
  835.                -e      The next argument is taken as a symbol defining  the
  836.                    entry address of the overlay or object output.
  837.  
  838.                -u      take the following argument as a symbol and enter it
  839.                    as  undefined  in  the symbol table.  This is useful for
  840.                    loading wholly  from  a  library,  since  initially  the
  841.                    symbol  table  is  empty  and an unresolved reference is
  842.                    needed to force the loading of the first routine.
  843.  
  844.                -l      This option is an abbreviation for a  library  name.
  845.                    -l  alone  stands  for  'liba.a',  which is the standard
  846.                    system library for MOS systems.  -lx stands for 'libx.a'
  847.                    where  x  is  any character.  A library is searched when
  848.                    its name is encountered, so the placement  of  a  -l  is
  849.                    significant.   The  MOS  libraries  are  kept in the MOS
  850.                    system directory and lk searches this directory for  the
  851.                    libraries defined by the -l switch.
  852.  
  853.                -x      do not preserve local (non-.globl)  symbols  in  the
  854.                    output  symbol table; only enter external symbols.  This
  855.                    option saves some space in the output file.
  856.  
  857.                -X      Save local symbols  except  for  those  whose  names
  858.                    begin  with  'L'.  This option is used by mcc to discard
  859.                    internally  generated  labels  while  retaining  symbols
  860.                    local to routines.
  861.  
  862.                -n      Arrange that when the output file is  executed,  the
  863.                    text  portion  will  be  read-only  and shared among all
  864.                    users executing the file.  This involves moving the data
  865.                    areas  up  the  the  first  possible  4K  word  boundary
  866.                    following the end of the text.  In an overlay  this  has
  867.                    the  effect  of  relocating  the data to the next memory
  868.                    page.
  869.  
  870.                -o      The next argument is taken the name  of  the  output
  871.                    file, this overrides the a.out default.
  872.  
  873.                -b      The next argument is taken as a  number  giving  the
  874.                    base address at which linking is to begin.  This is used
  875.                    to relocate overlays above the root.   An  octal  number
  876.  
  877.  
  878.                                         - 2 -
  879.  
  880.  
  881.  
  882.  
  883.           LK(I)                 15th. September 1981                 LK(I)
  884.  
  885.  
  886.                    may be given by using a leading zero (0).
  887.  
  888.           FILES
  889.                lib?.a   libraries
  890.                liba.a   MOS system library
  891.                lib1.a   TCP/IP/OPCON library
  892.                lib2.a   X25 library
  893.                libv.a   virtual MOS library
  894.                a.out    output file
  895.  
  896.           SEE ALSO
  897.                as(I), ld(I), ar(I)
  898.  
  899.           BUGS
  900.  
  901.           ORIGIN
  902.                MITRE, then Robert Cole at UCL.
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.  
  932.  
  933.  
  934.  
  935.  
  936.  
  937.  
  938.                                         - 3 -
  939.  
  940.  
  941.  
  942.           MCC(I)                15th. September 1981                MCC(I)
  943.  
  944.  
  945.  
  946.           NAME
  947.                mcc - C compiler and MOS system builder
  948.  
  949.           SYNOPSIS
  950.                mcc [{ tag] [-c] [-p] [-O] [-F] [-S] [-P] file ...  [}]
  951.  
  952.           DESCRIPTION
  953.                Mcc is the UNIX C compiler which is used to  produce  a  MOS
  954.                system  load file.  Mcc is very similar to cc(I) except that
  955.                the command line to the loader (ld(I) or lk(I)) causes a MOS
  956.                kernel  to  be  included  and  MOS  system  libraries  to be
  957.                searched.
  958.  
  959.                Arguments whose names end with '.c' are taken to be C source
  960.                programs; they are compiled, and each object program is left
  961.                on the file whose name is  that  of  the  source  with  '.o'
  962.                substituted  for  '.c'.   The '.o' file is normally deleted,
  963.                however, if a single C program is compiled and loaded all at
  964.                one go.
  965.  
  966.                If curly brackets are used in the argument list an  extended
  967.                memory  system (vMOS) is assumed.  For building vMOS systems
  968.                mcc will call lk rather than ld for linking.  Some expansion
  969.                is done by mcc for certain arguments in a vMOS system,
  970.                           "{ tag" becomes "{ _tag -b 0140000 -n"
  971.                                     "}" becomes "-l }"
  972.                Arguments  following  the  -e  switch  have  an   underscore
  973.                prepended  to  convert  C  symbols  to  overlay symbols, the
  974.                overlay tag is similarly treated.   The  virtual  kernel  is
  975.                loaded, and the DDT segment added to the lk command.
  976.  
  977.                Mcc will compare the modify dates on all source files  ('.s'
  978.                or  '.c') with any object files ('.o') of the same name.  If
  979.                the object file has a later modify date then the source file
  980.                is not compiled.
  981.  
  982.                The following flags are interpreted by mcc.   See  ld(I)  or
  983.                lk(I) for load-time flags.
  984.  
  985.                 -c      Suppress the loading phase of the compilation,  and
  986.                      force  an  object file to be produced even if only one
  987.                      program is compiled.
  988.  
  989.                 -p      Causes a production version of the MOS kernel to be
  990.                      loaded  (mosp.o).  The  default  MOS  kernel is mosr.o
  991.                      which includes DDT.
  992.  
  993.                 -O      Invoke an object-code optimizer.
  994.  
  995.  
  996.  
  997.                                         - 1 -
  998.  
  999.  
  1000.  
  1001.  
  1002.           MCC(I)                15th. September 1981                MCC(I)
  1003.  
  1004.  
  1005.                 -F      Force the compilation of a  source  file,  even  if
  1006.                      there is a later object code file available.
  1007.  
  1008.                 -S       Compile  the  named  C  programs,  and  leave  the
  1009.                      assembler-language   output   on  corresponding  files
  1010.                      suffixed '.s'.
  1011.  
  1012.                 -P      Run only the macro  preprocessor  on  the  named  C
  1013.                      programs,  and leave the output on corresponding files
  1014.                      suffixed '.i'.
  1015.  
  1016.                Other  arguments  are  taken  to  be  either   loader   flag
  1017.                arguments,   or   C-compatible  object  programs,  typically
  1018.                produced by an earlier cc or mcc run, or  perhaps  libraries
  1019.                of C-compatible routines.  These programs, together with the
  1020.                results of any compilations specified, are  loaded  (in  the
  1021.                order  given)  to  produce  a  loadable MOS system with name
  1022.                a.out.
  1023.  
  1024.           FILES
  1025.                file.c                          input file
  1026.                file.o                          object file
  1027.                a.out                           MOS system output
  1028.                /tmp/ctm?                       temporary
  1029.                /lib/c[01]                      compiler
  1030.                /ucl/mos/lib/mos[pr].o          MOS kernels
  1031.                /ucl/mos/lib/liba.a             MOS system library
  1032.                /ucl/mos/lib/lib[12v].a         MOS utility libraries
  1033.  
  1034.           SEE ALSO
  1035.                ''Programming in C- a tutorial,'' C Reference Manual,
  1036.                ld(I), lk(I), load(I)
  1037.  
  1038.           DIAGNOSTICS
  1039.                The diagnostics produced by C  itself  are  intended  to  be
  1040.                self-explanatory.   Occasional  messages  may be produced by
  1041.                the assembler or loader.  Of these, the most mystifying  are
  1042.                from  the  assembler,  in  particular  ''m,''  which means a
  1043.                multiply-defined external symbol (function or data).
  1044.  
  1045.           BUGS
  1046.  
  1047.           ORIGIN
  1048.                UCL - Robert Cole
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.                                         - 2 -
  1058.